home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 1 Issue 2 / PDCD-1 - Issue 02.iso / _utilities / utilities / 004 / _adhesive / manualtxt < prev    next >
Text File  |  1994-09-29  |  36KB  |  557 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. Adhesive
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. ⌐ 1994 George Taylor
  30.  
  31. Programmer Interface
  32.  
  33.  
  34. Introduction
  35.  
  36. Note that Adhesive is SHAREWARE - you may have to register for it.
  37.  
  38. What is Adhesive?
  39. Adhesive is a RISC-OS relocatable module which provides a means of sharing code between many programs. Procedures (code) are grouped together into objects which are shared between multiple applications ÿ in a similar way to the Shared C Library.
  40.  
  41. This documentation is designed to read from start to end, you should skip over bits which are not relevant to the programming language you wish to use. I do not claim to be good at writing documentation, if you have any questions or are unclear about something do not hesitate to get in contact and ask me.
  42.  
  43. Legal stuff
  44. The files ÉLicenseæ and ÉRegisteræ should be read. In short once you have registered you may use Adhesive with your own programs.
  45.  
  46. Summary of features
  47. Å    Code is more reusable, better software engineering practices and modularity.
  48. Å    Shared objects may be upgraded whilst applications are still using older versions - applications will still run (without modification) even if obsolete procedures are removed from new versions.
  49. Å    Save memory and application loading time by sharing code.
  50. Å    Full run-time linker which can handle circular dependencies and inheritance.
  51. Å    All compiled languages and BASIC can be used.
  52.  
  53.  
  54. Why use Adhesive?
  55.  
  56. What languages can I use?
  57. Adhesive objects must be written in either a compiled high level language (e.g. C, Pascal) or in assembler (e.g ObjAsm, BASIC assembler). Because of the way BASIC works, objects can not be written in pure BASIC.
  58.  
  59. Applications (users) which use objects can be written in any language (e.g. C, Pascal, BASIC, Assembler) which are capable of doing SWI (system) calls and calling (e.g. BASICæs CALL) machine code.
  60.  
  61. A special object is provided with Adhesive which allow you to call objects written in C and the Shared C Library from BASIC (using CALL).
  62.  
  63. Wimp or non-wimp?
  64. Adhesive objects can be used from command line programs, WIMP programs, interrupt handlers, relocatable modules ÿ in fact just about anywhere. You do not require the window manager to use Adhesive.
  65.  
  66. What versions of RISC-OS? Will it run on my RISC-PC?
  67. Adhesive requires RISC-OS version 3.10 or later. Adhesive has not been tested on a RISC-PC yet but the (few) system calls it performs are well documented under the RISC OS 3.10 programmers reference manuals ÿ there should be no problems on a RISC-PC.
  68.  
  69. Will it clutter up my RMA space?
  70. Adhesive itself is not very large (about 20K). Adhesive uses little workspace and only claims RMA space in 16K chunks to minimise the amount of fragmentation which occurs.
  71.  
  72. Why share code?
  73. Sharing code has several advantages:
  74. Å    Less memory is used if many applications are sharing code.
  75. Å    Loading time is reduced if the shared code is already in memory.
  76. Å    Better software engineering practices result, better modularisation can occur and software upgrades to a commonly used piece of code do not require many programs to be upgraded.
  77.  
  78. Why use Adhesive objects and not relocatable modules?
  79. Å    Adhesive objects are smaller than the equivalent relocatable module.
  80. Å    You do not require to get a module name from Acorn.
  81. Å    Adhesive objects are automatically removed from memory when they are no longer in use.
  82. Å    Relocatable modules need to contain supervisor SVC mode code, Adhesive objects can be written in mode independent / USR mode only code - resulting in better trap handling.
  83. Å    Calling procedures in Adhesive objects is much faster then an SWI. (Only one/two branch instructions).
  84. Å    If you use the DDE it is very simple to create Adhesive objects.
  85. Å    New versions of objects can Éinheritæ older versions.
  86.  
  87.  
  88. Terminology
  89. The following terms are used throughout this documentation and in many of the examples supplied with Adhesive.
  90.  
  91. object    An object is a collection of procedures which are grouped together. These procedures can be shared between many users. An object can gain access to procedures in other objects including earlier versions of itself.
  92.  
  93. user    A user is an application or relocatable module which has access to objects via Adhesive.
  94.  
  95. Note the terms object and user are mutually exclusive.
  96.  
  97. procedures    A procedure is a piece of code in an object. A procedure can have any entry/exit parameters and register bindings it wants (though you are recommend to use APCS as used by the C compiler). Adhesive is only interested in an address in memory to call to execute the procedure.
  98.  
  99. request    A user requests an object using Adhesive, objects can request other objects using Adhesive.
  100.  
  101.  
  102. How it works
  103. When Adhesive initialises it keeps a record of which objects are installed. A user then requests an object, Adhesive will load the object and any objects which are in turn required, Adhesive then creates branch instructions between the user and the object, and between objects and other objects if needed. The user simply then branches to the code in the object. (This is a branch table, like that used by the Shared C Library.) 
  104.  
  105. Adhesive takes care of finding a suitable version of an object and finding the objects which that object depends on. Circular dependencies are allowed, indeed an object may refer to itself or an older version of yourself allowing inheritance.
  106.  
  107. When a user Édiesæ Adhesive removes all objects which are no longer needed from memory.
  108.  
  109. Each object is kept in a directory along with any resources it needs. Adhesive provides easy message lookup for objects which require a messages file.
  110.  
  111. Installation
  112. The directory Étools.binæ contains some executables. These should by placed somewhere in your system which is in your Run$Path (e.g. library or bin directory).  The application Éadhesive.!Adhesiveæ should be placed in a place where it will be Éseenæ by the filer when your machine starts up. You can do this by adding a line Filer_Run .....!Adhesive to your !Boot file or if you have a RISC-PC you can place it in the boot directory.
  113.  
  114. If you have the Desktop Development Environment (DDE) then you may wish to use the supplied tool !CAHG (more on this later). If so you will need to place the lines below (with no extra blank lines or spaces) into your É!Make.toolsæ file. (Remove the ---CUT--- lines.)
  115. ÿÿCUTÿÿ
  116. CAHG
  117. cahg
  118. -u -t
  119. cahg $(cahgflags) $< -o $@
  120. DDE:!CAHG.desc
  121. DDE:!CAHG.!setup
  122. ÿÿCUTÿÿ
  123.  
  124. You should now reboot your machine (to ensure the newly installed copy !Adhesive is used rather than the one in the distribution archive).
  125.  
  126. If you distribute the copy of Adhesive in the Éuseræ directory to others with your software, please ensure that you provided appropriate installation instructions or installation program.
  127.  
  128. !Adhesive
  129. !Adhesive is an application which launches the Adhesive module. This involves loading the module and initialising Adhesive. During this initialisation it is possible that some errors will occur. If so all errors are logged in the !Adhesive.errorlog file and the error öAdhesive encountered one or more minor errors during initialisation,see the !Adhesive.errorlog file for detailsò will be reported.
  130.  
  131. Adhesive will still continue to run, however it is likely that these errors were caused by corrupt/invalid objects and so not all objects may be available. If a Éseriousæ error should occur it will be reported and the initialisation program will remove the Adhesive module from memory.
  132.  
  133.  
  134. Support for different languages
  135. The ideal environment to use Adhesive in is the Desktop Development Environment (DDE). If you do not have the DDE do not despair, examples written in BASIC are supplied.
  136.  
  137. APCS
  138. APCS (Arm Procedure Call Standard) is a defined way of calling procedures from one language to another. The RISC-OS programmers reference manual describes this. You are advised to make procedures in objects APCS conformant (in fact APCS-R conformant) so that your objects can be used from C,Pascal,Assembler,BASIC and other languages.
  139.  
  140. To use APCS you need to have initialised with the Shared C Library, see the section below on BASIC on how you can easily do this.
  141.  
  142. DDE (Desktop C,Pascal,Assembler)
  143. The directory Étoolsæ contains two DDE tools, !CAHG (C Adhesive Header Generator) and !Shorten. These tools are described in more detail later, choosing the Help option from the tools provides more information.
  144.  
  145. CAHG takes a short file describing which procedures your object offers and needs, or what objects your user needs. It generates a .o file ready for linking which contains information which Adhesive needs at run time. CAHG has support for !Make.
  146.  
  147. Also supplied are two .o files, Étools.o.Adhesiveæ and Étools.o.AdhesiveRSæ. These come with corresponding C header files in the Étools.hæ directory. These allow you to access Adhesive SWIæs from C, ÉAdhesiveæ is for users and ÉAdhesiveRSæ for objects. These objects files also work fine from Pascal and Assembler.
  148.  
  149. When compiling objects you should NOT link with Éstubsæ, you should not choose the module option for CC but MUST choose the module option for Link.
  150.  
  151. BASIC
  152. The directory Éexamplesæ contains an example object written in BASIC. The directory Égoodiesæ contains an object (basicC) which allows you to call APCS conformant procedures from BASIC (such as the Shared C Library or other objects written in C). Documentation and examples of this object are provided in the Égoodies.basicCæ directory.
  153.  
  154. Beebug Easy C
  155. You can create users and objects using Easy C though you will need to use a different linker for the following reasons:
  156. Å    The Easy C linker does not support a Émoduleæ option as so cannot generate relocatable code ÿ objects must be relocatable.
  157. Å    The Easy C linker does not like the .o files produced by CAHG. (The DDE has no problem.) I suspect this is because the type/version of .o file produced by cahg is of too recent a version.
  158. This applies to Easy C module version 1.99, I have not tested later versions. You can either use Acornæs Link or you can try using DrLink (sorry but I have not tried DrLink). I have had no problems when using Acornæs Link.
  159. You will have to run CAHG by hand from the command line.
  160.  
  161. GNU GCC
  162. You can create users and objects using GCC. You will need a linker which produces relocatable code (ie has a Émoduleæ option). I have had no problems when using Acornæs Link. You will have to run CAHG by hand from the command line.
  163.  
  164.  
  165. Objects
  166. Objects are contained in a directory along with their resources. The directory name indicates to Adhesive which object the object is (a unique identification number is used) and which version it is. No two objects installed at the same time may have the same object identification number and version number.
  167.  
  168. Object identification number and version number
  169. When you register (see the file Éregisteræ) you will be given a range of object identification numbers you can use (64 in fact). The following identification numbers are reserved: (All numbers are decimal.)
  170. 0    Not valid
  171. 1    Gives access to the Shared C Library (see The Shared C Library)
  172. 2-63    Reserved for testing and debugging purposes and the supplied examples.
  173. 64-127    You may use these object numbers whilst waiting for me to respond to your registration form and fee. Do not give objects using these numbers to others.
  174.  
  175. Generally speaking each object is kept in a directory with the name xxx.vvv where xxx is the objects identification number and vvv is the version number. These numbers should not have leading zeros and are in decimal and must not contain alphabetical characters. Version 1.00 has a vvv of 100. The version number must be greater than zero.
  176.  
  177. Only the directory name identifies the object number and name.
  178.  
  179. The object directory
  180. Each object must have the following files in the directory:
  181.     xxx.vvv.obj    This file is not optional and must be present.
  182.     xxx.vvv.info    This file is not optional and must be present.
  183.     xxx.vvv.messages    This file is optional.
  184. The Éobjæ file is the object itself, it is simply a piece of ARM code starting with a special Adhesive object header. Typically run time relocation code produced by Link is found at the end of the object. The object must not be compressed, it is expected to run in an amount of memory equal to the file size.
  185.  
  186. The Éinfoæ file describes the object. It must contain at least four lines, a title, an author, some version information and then a blank line. The blank line MUST be present for future compatibility. For example:
  187. Wimp Interface Object
  188. George Taylor
  189. Release 1.00, beta version, 10th January 1999
  190.  
  191. All lines after the above blank line are ignored.
  192.  
  193. Object resources
  194. If your object has a messages file it will be loaded by Adhesive when your object is loaded. You can access the messages using adhesive_Messages(), adhesive_Error() from C or you can use SWI Adhesive_Messages, Adhesive_Error. Do not supply a messages file unless you need one ÿ even an empty file will waste memory.
  195.  
  196. You can obtain the name of the directory your object is in (regardless of its number and version) using adhesive_Resource() or SWI Adhesive_Resource. Use this if your object requires resources such as sprite files, templates, lookup tables etc. You may use any file names you wish for these including directory structures.
  197.  
  198. Installing and removing objects
  199. When you create a new version of an object you MUST give it a HIGHER version number. Adhesive will not allow you to replace an object/version combination which already exists without explicitly deleting the old one first.
  200.  
  201. To install an object you can use
  202.     *Adhesive_InstallObject <filename>
  203. where <filename> is of the form Épath.xxx.vvvæ which is a directory containing the object and its resources. The directory is copied recursively if the object is installed. No action (or error is reported) if the object number/version is already installed. See also SWI Adhesive_InstallObject.
  204.  
  205. To remove an object you can use
  206.     *Adhesive_RemoveObject xxx vvv
  207. where xxx is an integer object identification number and vvv is an integer version number (use 100 for V1.00). An error is given if the object is not installed or if the object is currently in use.
  208.  
  209. The Shared C Library
  210. Users of Adhesive objects written using C,Pascal,ObjAsm should use the Shared C Library via the Éstubsæ file provided with the DDE.
  211.  
  212. Users of Adhesive objects written in BASIC should use the basicC object provided in the Égoodiesæ directory. Machine code programs written using the BASIC assembler will have to register with the Shared C Library themselves. (An example of this is supplied in the Adhesive Objects distribution also written by George Taylor, alternatively you can use the example given in the PRMæs. No example of this is currently provided with Adhesive).
  213.  
  214. Objects written in any language should not register with the Shared C Library. This is because objects are intended to behave as library extensions to programs. A program written in C will use APCS. This program can then call an object which then calls the Shared C Library using the environment set up by the program.
  215. You should do this by requesting object 1 (a special object built in to Adhesive which gives direct access to the Shared C Library). This means when you open a file the C FILE* descriptor is kept in the user programs memory space - as you would expect to happen.  malloc() and free() also behave correctly for example.
  216.  
  217. Notes:
  218. Å    You do not need to check the Shared C Library is loaded, it must be for Adhesive to work. This means object 1 can always be requested (provided Adhesive is loaded).
  219. Å    The minimum and maximum version of object 1 are ignored. You will get whatever version of the Shared C Library is currently loaded.
  220.  
  221.  
  222. Procedures and how Adhesive chooses which version of an object to use
  223. Procedures are a piece of code with any entry/exit definitions you care to use though APCS-R is the preferred system for maximum compatibility and code reuseability. Procedures within an object are given entry point numbers, these are 32bit integer numbers and include 0. Entry point numbers do not need to follow any order and are local to a particular object identification number (but must be consistent across versions of the same object). (Your object will be slightly shorter if the numbers are contiguous.)
  224.  
  225. Identifying procedures by numbers also means that if you do not like the procedure names that come with an object (then provided you change the C header file if using C) you can use whatever names you like for the procedures.
  226.  
  227. An object defines which entry points it offers. This is defined in a special header at the start of a object along with details of which other objects the object needs. (CAHG will generate this header for you.) A user must specify which entry points it requires when requesting other objects.
  228.  
  229. When you request an object you specify which object, which range of versions, and which entry points. Adhesive will give you highest version of the object possible such that
  230. Å    The version provides all the entry points asked for.
  231. Å    The version is greater than or equal to your specified minimum version.
  232. Å    The version is less than or equal to your specified maximum version.
  233. Å    The object loads and initialises successfully.
  234.  
  235. This mechanism ensures it is possible to both add new procedures to newer versions of objects and to remove obsolete procedures from newer versions whilst still allowing programs to run. (The older program doesnæt even need to know about the new object version, it simply requests the highest version possible and gets the old version as the new version has had some obsolete procedure removed).
  236.  
  237. If the object does not load successfully (due to a reason other than lack of memory) then Adhesive tries again with a lower version of the object if a suitable one is available. This process can repeat itself as many times as possible.
  238.  
  239. If an object fails to load (due to a reason other than lack of memory) then no attempt is made to try and load the object again until a new object is installed or Adhesive is restarted. This is because:
  240. Å    If the object failed to load due to reporting an error (eg missing resource file) or the object being corrupted there is no point in trying to load it again - it will only fail.
  241. Å    Most objects fail to load because they require other objects which are not installed. There is no point in trying to load the object again until new objects have been installed.
  242. The tool Étools.bin.AdhInfoæ is particularly useful in finding out the error status of objects.
  243.  
  244. The dummy object 1 provides access via this mechanism to the Shared C Library.
  245.  
  246.  
  247. Writing objects
  248. The examples provided both in this distribution and in the separate distribution of freeware objects written by George Taylor are the best way of learning how to write objects. If you are using CAHG you should read the !CAHG.!Help file before using CAHG.
  249.  
  250. There are however a few important points to note:
  251. Å    Global variables are global to your object regardless of the user who calls you.
  252. Å    If you use an APCS (C like) environment, then the environment the object Éseesæ is the same as the user currently calling the object. (For example if you use fopen() then the returned file descriptor will be in the useræs memory space NOT yours.)
  253. Å    I believe there may be a problem of zero-initialised data areas not being initialised. Assume that global variables are not initialised to 0 unless you specify an initialisation value when you declare the variable.
  254. Å    Never choose the Émoduleæ option on the C compiler.
  255. Å    Always choose the Émoduleæ option on the linker. If you donæt your object will crash.
  256. Å    Objects must not register as a user with Adhesive.
  257. Å    Objects must not be squeezed using !Squeeze.
  258. Å    If you wish to inherit an older version of yourself simply request versions greater than some minimum which is less than your own version.
  259. Å    See also Éabstract typesæ below.
  260.  
  261.  
  262. Abstract types - problems that can arise - warning this is complex!
  263. Later versions of objects must provide an interface which is compatible with earlier versions. If you use malloc() to claim space, pass back a pointer to abstract data stored at this space. You need not keep the abstract data format the same between versions of objects.
  264.  
  265. Important point illustrated by a (complex) example:
  266.  
  267.   i )    object C, version 1 provides an abstract hash table type (it uses say open addressing).
  268.     For example:
  269.     typedef void *hashtable;
  270.     hashtable add(hashtable h,char *string)
  271.   ii)    suppose object A uses C to provide hashing of strings
  272.   iii)    suppose object B also uses C to provide hashing of strings
  273.   iv)    the procedures in A & B take/return an abstract hash table pointer which is actually passed straight to C
  274. v)    user U requests A
  275. vi)    Adhesive loads A and C version 1 and links Cv1 to A and A to U.
  276. vii)    someone installs object C, version 2 which whilst providing the same call interface now uses probing instead of open addressing
  277. viii)    user U requests B
  278. ix)    Adhesive loads C, version 2 (its the latest version) and links Cv2 to B and B to U.
  279. x)    user U calls a procedure in B with a hash table he created from A.
  280. xi)    something nasty happens because Cv2 uses a different data representation to Cv1.
  281.  
  282. Alternatively A and B could specifically request different versions of C and the same problem would occur.
  283.  
  284. Conclusion:
  285. When you request an object you must assume itæs abstract types are different from other requests of the object (including those indirectly through other objects).
  286.  
  287. The way to avoid this problem all together is not to Éshareæ abstract  types between objects. (Which with abstract types is generally a bad thing to do anyway.)
  288.   
  289. [ Personally I much prefer the SML module system, it has proper data types and a secure type system. ]
  290.  
  291. Similarly if you place more than one request for the same object in an object request table they may not be linked to the same version.
  292.  
  293.  
  294. Examples
  295. There are examples in the Éexamplesæ directory, there is also an example in Égoodies.basicCæ. The examples include documentation.
  296.  
  297. Tools
  298. The following tools are provided with Adhesive, they may be found in the Étools.binæ directory. CAHG and Shorten also come with DDE frontends.
  299. CAHG    C Adhesive Header Generator. Generates the request and offer blocks described in  ÉTechnical Bitsæ from a simple text file description.
  300. Shorten    Remove the relocation code produced by Link from the end of an object if the object contains no relocations. This will simply make the object a little bit shorter if possible. It also change the objectæs filetype from Émoduleæ to Édataæ.
  301. KillAll    Makes Adhesive think all users have died and removes all objects from memory. This can be useful when debugging your own users and objects and Adhesive thinks an object is still in use because a user did not exit properly.
  302. AdhInfo    Display information on all installed objects and currently running users.
  303. AdhObjInfo    Displays full information on an object or on all installed objects.
  304. The file Étools.readmeæ contains more details on these tools.
  305.  
  306. Technical bits
  307. This section describes the format of an object header (at the start of an object) and describes the SWIs supplied by Adhesive.
  308.  
  309. Some of the SWIs can be accessed from an APCS (C like) high level language using the Étools.o.Adhesiveæ and Étools.o.AdhesiveRSæ files. If you are writing in C/Pascal/Objasm you are advised to use the .o files as it makes things simpler. You are also advised to use !CAHG which will generate much of the Édata blocksæ described below for you from a simple text file.
  310.  
  311. Important notes:
  312. Å    All fields marked reserved for future use must be 0 when supplying data to Adhesive.
  313. Å    All Adhesive SWIs may be called from applications and modules unless indicated otherwise.
  314. Å    Adhesive SWIs are not re-entrant and must not be called from interrupts unless specified otherwise. The interrupt status is undefined.
  315. Å    Unless indicated otherwise all Adhesive SWIs may generate an error (use the X version to trap the error).
  316. Å    Registers not listed below as part of the exit status from Adhesive SWIs are preserved.
  317. Å    All strings must be 0 terminated.
  318. Å    All parameter blocks must be word aligned. Strings can be byte aligned.
  319.  
  320. SWIs
  321. The SWIs below are offsets from Adhesiveæs SWI base number of &4A140.
  322.  
  323. Adhesive_Register    &00
  324.     entry:    r0 = pointer to user information block (see later), a copy of this is
  325.         made so you may dispose of it after this call
  326.     exit:    r0 = handle
  327.     use:    Register a new user with adhesive. The returned handle is non-zero.
  328.         You can register as a user as many times as you like - once is normally
  329.         enough - this is useful if you wish to only use some objects during program
  330.         startup.
  331.  
  332. Adhesive_Deregister    &01
  333.     entry:    r0 = handle (as returned by Adhesive_Register)
  334.     exit:    no exit parameters
  335.     use:    Tell Adhesive you are no longer using previously requested objects.
  336.         After making this call you must not make any further calls to objects
  337.         requested on the handle or pass the handle to any SWIs.
  338.  
  339. Adhesive_Request    &02
  340.     entry:    r0 = handle
  341.         r1 = pointer to request block (see later), a copy of this information is made so 
  342.         you may dispose of the block after the call.
  343.     exit:    no exit parameters
  344.         If this call does not give an error you may now call procedures in the
  345.         requested objects.
  346.  
  347. Adhesive_Resource    &03
  348.     entry:    r0 = pointer to the start of your object header
  349.     exit:    r0 = pointer to read-only directory name
  350.     use:    Ask Adhesive for the name of the directory your object is in. It will end in
  351.          xxx.vvv with a 0 terminator.
  352.          
  353.          You must not write to the returned string, doing so may cause
  354.         improper operation later.
  355.  
  356.          This SWI is re-entrant and the string returned will be valid as long as your
  357.         object is loaded.áDo not refer to the string after your objectæs finalisation entry
  358.         has returned.
  359.  
  360.         Typically you would use this SWI to access a resource file your object
  361.          requires.
  362.         
  363.         This call must only be made by an object which is currently in memory.
  364.  
  365. Adhesive_KillAll    &04
  366.     entry:    no parameters
  367.     exit:    all register preserved
  368.     use:    Deregisters all users and removes all objects from memory.
  369.         Do not use this SWI whilst there are users actively using objects.
  370.         This SWI is useful when debugging objects.
  371.         The program Étools.bin.KillAllæ uses this SWI.
  372.  
  373. Adhesive_ToolSupport    &05
  374. Adhesive_Init    &06
  375. Adhesive_Debug    &07
  376. These SWIs are for internal use by Adhesive and the support tools only. You must not use them in your own programs, undefined results may occur if you do.
  377.  
  378.  
  379. Adhesive_InstallObject    &08
  380.     entry:    r0 = pointer to directory name of object to install
  381.     exit:    r0 = 0 if object already installed, 1 if object just installed
  382.     use:    Installs a new object, the object directory is recursively copied and the object
  383.         made ready for use. No action is taken if the object/version is already
  384.         installed.
  385.  
  386. Adhesive_RemoveObject    &09
  387.     entry:    r0 = object number
  388.         r1 = version
  389.     exit:    no exit parameters
  390.     use:    Removes an object if it is not in use.
  391.  
  392. Adhesive_Messages    &0A
  393.     entry:    r0 = pointer to the start of your object header
  394.         r1 = pointer to message token (zero terminated) (may have default :string)
  395.         r2 = pointer to buffer for result, 0=>no buffer
  396.         r3 = size of buffer (ignored if r2=0)
  397.         r4...r7 = pointers to parameters %0...%3 (ignored if r2=0)
  398.         (you may miss out registers which correspond to parameters not used in
  399.         the messages file)
  400.  
  401.     exit:    r0 = pointer to buffer or pointer to read-only message if r2=0 on entry
  402.         0=> no message file found or tag not found
  403.         The message is terminated with a 0 if r2<>0 on entry. If r2=0 on entry the
  404.         message is terminated with a ctrl character. (MessageTrans does this.)
  405.  
  406.     use:    Lookup a message from the objectæs messages file. You may supply a default
  407.         message after the tag, e.g. tag:default.
  408.          
  409.          You must not write to the returned string if r2=0 on entry doing so may cause
  410.         improper operation later.
  411.  
  412.          This SWI is re-entrant and the string returned at r0 if r2=0 on entry
  413.          will not be overwritten as long as the object is loaded.
  414.         Do not refer to the string after your objectæs finalisation entry
  415.         has returned.
  416.  
  417.         This call never returns an error but you should use the X version anyway -
  418.         in case an address exception or similar occurs.
  419.         This call must only be made by an object which is currently in memory.
  420.  
  421. Adhesive_Error    &0B
  422.     entry:    r0 = pointer to the start of your object header
  423.         r1 = pointer to word aligned error block containing error number and
  424.         zero terminated message token.
  425.         r2...r5 = pointers to parameters %0...%3
  426.         (you may miss out registers which correspond to parameters not used in
  427.         the messages file)
  428.  
  429.     exit:    r0 = pointer to read-only error block containing error number and message
  430.         If the tag could not be found a pointer to the error block passed in r1 on entry
  431.         is returned. This is a MessageTrans internal error block, note there are ten of
  432.         these for foreground processes and two for IRQ processes.
  433.  
  434.     use:    Lookup a message from the objectæs messages file but using an error block.
  435.          
  436.          This SWI is re-entrant. The error block's contents may change if further calls
  437.         to the message trans module are made. See the documentation on
  438.         MessageTrans in the programmers reference manual for more information on
  439.         message trans internal error buffers.
  440.  
  441.         Typically you would use this SWI to return error messages during your
  442.         initialisation entry. 
  443.  
  444.         This call never returns an error but you should use the X version anyway -
  445.         in case an address exception or similar occurs.
  446.         This call must only be made by an object which is currently in memory.
  447.  
  448. Parameter blocks
  449. There are three parameter block types, an object header, a request and a user information block. Some of these include another structure known as Épairsæ.
  450.  
  451. User information
  452.        offset from start of block        description
  453.     0        flags, currently none used, must be 0
  454.     4        Pointer to zero terminated string identifying who you are,
  455.             this is used for information purposes only and need not be 
  456.             unique.
  457.  
  458. Object Header
  459. An object (both the file on disk and in memory) have the following layout:
  460.        offset from start of object    description
  461.     0        B __RelocCode or 0 if object has no relocation code
  462.     4        B initialisation code or 0 if none
  463.     8        B finalisation code or 0 if none
  464.     12        reserved for future use, must be 0
  465.     16        reserved for future use, must be 0
  466.     20        reserved for future use, must be 0
  467.     24        reserved for future use, must be 0
  468.     28        reserved for future use, must be 0
  469.     32        number of branches in branch table
  470.     36        number of pairs
  471.     40...        pairs
  472.     ...-...        branches (branch table, you supply this)
  473.     ...        requests (see below)
  474.     ...        rest of object (e.g. code!)
  475. Note the branch table above MUST contain branch (B) instructions. This is because Adhesive decodes the instruction to find the address of the procedure. (Branches do not produce relocations in compiled code and so donæt add to the object size - an absolute address would do this. Offsets are not practical accross multiple .o files.)
  476.  
  477. Request
  478.        offset from start of request    description
  479.     0        object identification number or 0 to mark end of table
  480.     4        minimum version (e.g. 100 for 1.00), this may be 0
  481.     8        maximum version (normally 0 (ie no max) except for an object
  482.             inheriting and earlier version of itself)
  483.     12        reserved for future use, must be 0
  484.     16        number of branches to be placed in branch table
  485.     20        number of pairs to follow
  486.     24...        pairs
  487.     ...-...        branches (branch table filled in by Adhesive)
  488. More than one request can be placed after another but note that a zero word must always mark the end of the table.
  489.  
  490. Pairs
  491. Pairs provide a compact means to represent a range of numbers. A pair consists of two integers, for example:
  492.     1
  493.     5
  494.     9
  495.     10
  496.     12
  497.     12
  498. These two pairs indicate entry points 1,2,3,4,5,9,10,12 are offered/requested. The pairs must be in ascending order and must be in Ésimplestæ form. So for example,
  499.     0
  500.     5
  501.     6
  502.     8
  503. are not in simplest form. (It can be written 0-8).
  504.  
  505. Relocation entry point
  506. An object has a relocation entry point to enable non-relocatable code to relocate itself. This relocation code is typically the __RelocCode produced by Link. It is called before any other entry point into the object and before any procedures in the object are called.
  507.  
  508. __RelocCode is called when an object is loaded, it must not call any other objects or Adhesive SWIs.
  509.     entry:    SVC stack at R13   (processor is in SVC mode)
  510.         return address in R14
  511.     exit:    You may corrupt all registers.
  512.  
  513. Initialisation entry point
  514. The initialisation code is called after the __RelocCode entry has been called but before any procedures in object are called. It must not call any other objects (as your object may not have been linked yet). You may not call Adhesive SWIs other than Adhesive_Resource, Adhesive_Messages and Adhesive_Error.
  515.     entry:    SVC stack at  R13 (processor is in SVC mode)
  516.         return address in R14
  517.     exit:    R0 = return value
  518.             0 => no error
  519.             -1 => not enough memory
  520.             non-zero => pointer to word aligned RISC-OS error block
  521.                 (max of 256 bytes: 32bit number, zero terminated string)
  522.         You may corrupt all other registers.
  523.  
  524. Note this is not an APCS register setup, be very careful if you write this entry point in C. You are advised to write this in assembler. If you know you have failed to initialise because of a lack of memory (and not a missing file or other error) then please return -1. This means Adhesive will assume it is not worth trying lower versions of the object and it is worth trying this version again later.
  525.  
  526. Finalisation entry point
  527. The finalisation code is called before your object is removed from memory. It must not call any other objects (as they may already have been removed). You may not call Adhesive SWIs other than Adhesive_Resource, Adhesive_Messages and Adhesive_Error.
  528.     entry:    SVC stack at R13 (processor is in SVC mode)
  529.         return address in R14
  530.     exit:    no return value
  531.         You may corrupt all registers.
  532. Note this is not an APCS register setup, be very careful if you write this entry point in C. You are advised to write this in assembler.
  533.  
  534.  
  535.  
  536. Final notes
  537. Å    Adhesive does not support *RMTidy. Do NOT use RMTidy when Adhesive is running.
  538. Å    The supplied binary Étools.o.KillAllæ will kill all users and remove all objects from memory without any safety checks.
  539. Å    Once an object is loaded in memory it will not be removed until it is no longer in use. It will not be relocated once loaded.
  540. Å    Upon a Service_Reset occurring Adhesive will assume all users have died and will remove all objects from memory. Modules must reregister upon a Service_Reset.
  541.  
  542.  
  543. The Adhesive module name, SWI chunk name, SWI chunk number and the environment variables listed below have been allocated from Acorn.
  544. The SWI chunk name (Adhesive), SWI names (see above section) and the SWI chunk number (&4A140) are never going to change. This means software which depends on these names will continue to word across all future versions of Adhesive.
  545.  
  546. Environment variables used by Adhesive:
  547.     Adhesive$ErrorFile    All Adhesive errors are logged to this file
  548.     Adhesive$InstallPath    New objects are placed in this directory
  549.     Adhesive$ObjectPath    Objects are kept in this directory.
  550. The reason for having a separate InstallPath from ObjectPath is so that multiple directories can be placed in the ObjectPath (e.g. if your filing system has a limit on directory entries). (Writing to a path with multiple entries produces an error.)
  551. Do not use these variables in your own programs. Adhesive's use of them may change in future versions.
  552.  
  553. You may however use <Adhesive$ObjectPath> in your C header files (or such like) to access header files which may be contained within an object.
  554.  
  555. You may also change the !Adhesive.!Run file to suit your system. (Do not modify the copy you give to others though.) You can also change the !Adhesive.!Boot file to alter the way Adhesive boots.
  556.  
  557.